using System;
using System.Collections.Generic;
using SouthernLand.Common.DAL.NhaDat;

namespace SouthernLand.Common.BOL.NhaDat
{
    public class Raovat
    {
        #region Public Properties

        public Int32 RaovatID { get; set; }

        public String UserID { get; set; }

        public Int32 CateID { get; set; }

        public Int32 Loaitin { get; set; }

        public Int32 Tinhthanh { get; set; }

        public Int32 Quanhuyen { get; set; }

        public String DiachiNha { get; set; }

        public Double DientichDat { get; set; }

        public Double DientichXD { get; set; }

        public Double DientichSD { get; set; }

        public Int32 Solau { get; set; }

        public Int32 PhongNgu { get; set; }

        public Int32 PhongVS { get; set; }

        public Int32 TinhtrangPL { get; set; }

        public Int32 HuongNha { get; set; }

        public String Vitri { get; set; }

        public Int32 DuongtruocNha { get; set; }

        public Decimal Gia { get; set; }

        public Int32 DonVT { get; set; }

        public String GiaTren { get; set; }

        public String Tieude { get; set; }

        public String Mota { get; set; }

        public String Hinh1 { get; set; }

        public String Hinh2 { get; set; }

        public String Hinh3 { get; set; }

        public String Hinh4 { get; set; }

        public String Hinh5 { get; set; }

        public String Hoten { get; set; }

        public String Diachi { get; set; }

        public String Email { get; set; }

        public String Dienthoai { get; set; }

        public String Didong { get; set; }

        public DateTime AddedDate { get; set; }

        public DateTime ExpireDate { get; set; }

        public Int32 DisplayOrder { get; set; }

        public Boolean IsActive { get; set; }

        public Int32 TotalViews { get; set; }

        public Int32 TotalRecords { get; set; }

        #endregion

        #region public static Methods

        public static List<Raovat> GetRaovatHethan(string strSort, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatHethan(strSort, PageIndex, PageSize);
        }

        public static List<Raovat> Search(eTrangthai Trangthai, string Keyword, Raovat objRaovat, string strWhereGia,
                                          int DonVT, string strWhereDienTichDat, string Sort, int PageIndex,
                                          int PageSize)
        {
            var db = new RaovatDAL();
            return db.Search(Trangthai, Keyword, objRaovat, strWhereGia, DonVT, strWhereDienTichDat, Sort, PageIndex,
                             PageSize);
        }

        public static List<Raovat> GetRaovatDaLuu(String UserID, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatDaLuu(UserID, PageIndex, PageSize);
        }

        public static bool GiaHan(Int32 RaovatID, int SoNgay)
        {
            var db = new RaovatDAL();
            return db.GiaHan(RaovatID, SoNgay);
        }

        public static List<Raovat> GetRaovatHetHanByUser(String UserID, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatHetHanByUser(UserID, PageIndex, PageSize);
        }

        //Get Raovat moi nhat theo LoaitinID
        public static List<Raovat> GetRaovatMoiNhat(int LoaitinID)
        {
            var db = new RaovatDAL();
            return db.GetRaovatMoiNhat(LoaitinID);
        }


        public static int Insert(Raovat obj)
        {
            var db = new RaovatDAL();
            return db.Insert(obj);
        }

        public static bool Update(Raovat obj)
        {
            var db = new RaovatDAL();
            return db.Update(obj);
        }

        public static bool Delete(Int32 RaovatID)
        {
            Raovat obj = GetRaovatByID(RaovatID);
            FileProcess.DeleteFile(Globals.PhysicalApplicationPath() + "UserUpload/NhaDat/" + obj.Hinh1);
            var db = new RaovatDAL();
            bool raovatDeleted = db.Delete(RaovatID);
            if (raovatDeleted)
            {
                var rvSave = new RaovatSaveDAL();
                return rvSave.DeleteByRaovatId(RaovatID);
            }
            return false;
        }

        public static Raovat GetRaovatByID(Int32 RaovatID)
        {
            var db = new RaovatDAL();
            return db.GetRaovatByID(RaovatID);
        }

        //Get All Raovat
        public static List<Raovat> GetAllRaovat()
        {
            var db = new RaovatDAL();
            return db.GetAllRaovat(1, 10000);
        }


        //Get All Raovat
        public static List<Raovat> GetAllRaovat2(string strSort, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetAllRaovat2(strSort, PageIndex, PageSize);
        }


        //Get All Raovat
        public static List<Raovat> GetAllRaovat(int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetAllRaovat(PageIndex, PageSize);
        }

        // Get Count All records of Table  Raovat
        public static int GetCountRaovat()
        {
            var db = new RaovatDAL();
            return db.GetCountRaovat();
        }

        // Get RaovatByUserID
        public static List<Raovat> GetRaovatByUserID(String UserID, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatByUserID(UserID, PageIndex, PageSize);
        }


        // Get RaovatByCateID
        public static List<Raovat> GetRaovatByCateID(Int32 CateID, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatByCateID(CateID, PageIndex, PageSize);
        }

        // Get RaovatByLoaitin
        public static List<Raovat> GetRaovatByLoaitin(Int32 Loaitin, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatByLoaitin(Loaitin, PageIndex, PageSize);
        }

        // Get RaovatByTinhthanh
        public static List<Raovat> GetRaovatByTinhthanh(Int32 Tinhthanh, int PageIndex, int PageSize)
        {
            var db = new RaovatDAL();
            return db.GetRaovatByTinhthanh(Tinhthanh, PageIndex, PageSize);
        }


        // Get RaovatCountByUserID
        public static int GetRaovatCountByUserID(String UserID)
        {
            var db = new RaovatDAL();
            return db.GetRaovatCountByUserID(UserID);
        }

        // Get RaovatCountByCateID
        public static int GetRaovatCountByCateID(Int32 CateID)
        {
            var db = new RaovatDAL();
            return db.GetRaovatCountByCateID(CateID);
        }

        // Get RaovatCountByLoaitin
        public static int GetRaovatCountByLoaitin(Int32 Loaitin)
        {
            var db = new RaovatDAL();
            return db.GetRaovatCountByLoaitin(Loaitin);
        }


        // Get RaovatCountByTinhthanh
        public static int GetRaovatCountByTinhthanh(Int32 Tinhthanh)
        {
            var db = new RaovatDAL();
            return db.GetRaovatCountByTinhthanh(Tinhthanh);
        }

        #endregion
    }
}